<?php
$this->breadcrumbs=array(
    'Menu'=>array('index'),
    'Manage',
);
?>
<div class="contentwrapper"><!--Content wrapper-->
<div class="alert alert-info">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <p><strong>
            <span class="icon16  brocco-icon-mic"></span>
            <?php echo t('You may optionally enter a comparison operator at the beginning of each of your search values to specify how the comparison should be done.','search'); ?>
        </strong></p>
</div>
<?php
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
    'filter'=>$model,
    'type'=>'striped bordered',
    'dataProvider' => $model->search(),
    'template' => "{pager}\n{items}\n{extendedSummary}\n{pager}",
    'id'=>'menu-grid',
    'responsiveTable'=>true,
    'bulkActions' => array(
        'actionButtons' => array(
            array(
                'buttonType' => 'button',
                'type' => 'primary',
                'size' => 'small',
                'label' => t('Delete','fcms'),
                'click' => 'js:function(checked){
                     var values = [];
                     checked.each(function(){
                         values.push($(this).val());
                     });
                    bootbox.confirm("'.t('Are you sure that you want to permanently delete the selected menu ?','fcms').'", function(result) {
                  if(result){
                  $.ajax({
                     url:"'.url('/menu/batchDelete').'",
                     cache:false,
                     type:"POST",
                     data: {ids:values.join(","),'.csrfTokenName().':"'.csrfToken().'"},
                     success:function(data){
                         $("#menu-grid").yiiGridView("update");
                        }
                        });
                      }
                    });
                }'
            ),
        ),
        // if grid doesn't have a checkbox column type, it will attach
        // one and this configuration will be part of it
        'checkBoxColumnConfig' => array(
            'name' => 'id',
            'checkBoxHtmlOptions'=>array('class'=>'nostyle')
        ),
    ),
    'columns'=>array(
        array(
            'name' => 'name',
            'value'=>'ucfirst($data->name)',
            'filter'=> $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                //'name'=>'title',
                'id'=>'titleAutoComplete',
                'model'=>$model,
                'attribute'=>'name',
                'sourceUrl'=>url('/menu/autocomplete'),
                'options'=>array(
                    'minLength'=>'2',
                ),
                'htmlOptions'=>array(
                    'size'=>'36',
                ),
            ), true),
            'htmlOptions'=>array(
                'style'=>'text-align:left'
            ),
        ),
        array(
            'name' => 'created_date',
            'value'=>'renderTime($data->created_date)',
            'filter'=> $this->widget('bootstrap.widgets.TbDateRangePicker', array(
                //'name'=>'title',
                //'id'=>'Content_active_date_filter',
                'model'=>$model,
                'attribute'=>'created_date_range',
                'options' => array(
                    'format'=>locale()->getDateFormat('short'),
                ),
                'htmlOptions'=>array(
                    'size'=>'36'
                ),
            ), true),
            'type'=>'raw',
        ),
        array(
            'name'=>'id',
            'headerHtmlOptions'=>array('width'=>'30px')
        ),
        array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'template' => '{update}{delete}',
        ),
    ),
)); ?>
</div><!-- End #Contenwapper -->